<template>
	<view class="content">
		<image mode="widthFix" :src="data.picUrl" class="top-bg"></image>
		<view class="detail-block">
			<view class="info-block">
				<image mode="aspectFill" :src="data.picUrl" class="photo"></image>
				<view class="info">
					<view class="name">{{data.specialty.speName}}</view>
					<view class="score-block">
						<view class="score">{{data.specialty.score}}</view>
					</view>
					<view class="ranking-block">
						<view class="ranking">{{data.ranking}}</view>
					</view>
				</view>
			</view>
			<view class="business-hours">
				<view class="date">
					营业时间：{{data.specialty.startTime?data.specialty.startTime:''}}-{{data.specialty.endTime?data.specialty.endTime:''}}
				</view>
			</view>
			<view class="business-hours" @click="callPhone">
				<view class="date">联系电话：{{data.specialty.mobile?data.specialty.mobile:''}}</view>
				<view class="iconfont icon-youjiantou"></view>
			</view>
			<view class="position-block" @click="openMap">
				<view class="position">
					<view class="iconfont icon-dingweixiao"></view>{{data.specialty.address?data.specialty.address:''}}
				</view>
				<view class="navigator-block">
					<view class="iconfont icon-daohang"></view>
					<view class="label">到这去</view>
				</view>
			</view>
		</view>
		<view class="title1">商品详情</view>
		<view class="block photo-block">
			<view class="name">{{data.shopName}}</view>
			<image mode="widthFix" :src="data.picUrl" class="photo"></image>
			<view class="price-block">
				<view class="discount-prices">{{data.price}}</view>
			</view>
		</view>
		<view class="block detail-block">
			<view class="title">商品详情</view>
			<view class="detail-content">
				<mp-html :content="data.proDetails" />
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		postSpecialtyDetail
	} from '@/api/speciaties.js';
	export default {
		data() {
			return {
				data: {}
			}
		},
		methods: {
			openMap() {
				uni.openLocation({
					longitude: this.data.specialty.longitude,
					latitude: this.data.specialty.latitude,
					name: this.data.specialty.speName,
					address: this.data.specialty.address,
				})
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.data.specialty.mobile,
					success() {
						console.log('拨打成功了');
					},
					fail() {
						console.log('拨打失败了');
					}
				})
			},
			selectDetail() {
				console.log(1)
				postSpecialtyDetail({
					id: this.data.id
				}).then((res) => {
					if (res.code == 1) {
						if (res.data != null) {
							this.data = res.data
							console.log(this.data)
						}
					} else {
						console.log(res)
					}
				}).catch((res) => {
					console.log(res)
				})
			},
		},
		onLoad(e) {
			this.data.id = e.id;
			this.selectDetail()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		background: #F4F4F4;
		min-height: 100vh;

		.top-bg {
			width: 100%;
			height: auto;
			filter: blur(5px);
		}

		.detail-block {
			position: relative;
			border-radius: 5px;
			background: #fff;
			width: calc(100% - 80rpx);
			margin: 0 auto;
			margin-top: -120rpx;
			padding: 30rpx;
			padding-bottom: 0;
			display: flex;
			flex-direction: column;

			.info-block {
				display: flex;
				flex-direction: row;
				padding-bottom: 30rpx;
				border-bottom: 1px solid #efefef;

				.photo {
					width: 180rpx;
					height: 180rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
				}

				.info {
					width: calc(100% - 200rpx);
					display: flex;
					flex-direction: column;
					padding-bottom: 10rpx;

					.name {
						font-size: 34rpx;
						font-weight: bold;
					}

					.score-block {
						display: flex;
						align-items: center;
						margin-top: 48rpx;

						.score {
							flex-grow: 0;
							font-size: 34rpx;
							font-weight: bold;
							margin-right: 14rpx;
							background: url('@/static/bottom.png') no-repeat;
							background-position: center 85%;
							background-size: 80%;
						}

						.capite {
							flex-grow: 0;
							font-size: 26rpx;
							color: $color-secondary-text;
						}
					}

					.ranking-block {
						display: flex;
						margin-top: 4rpx;

						.ranking {
							font-size: 24rpx;
							background: #FCF5E1;
							color: #dba81c;
							padding: 0 4rpx;
							border-radius: 8rpx;
						}
					}
				}
			}

			.business-hours {
				border-bottom: 1px solid #efefef;
				display: flex;
				flex-direction: row;
				align-items: center;
				height: 80rpx;
				font-size: 28rpx;

				.iconfont {
					font-size: 26rpx;
					color: #999;
				}

				.date {
					flex-grow: 1;
				}
			}

			.position-block {
				display: flex;
				flex-direction: row;
				align-items: center;
				font-size: 28rpx;
				height: 120rpx;

				.position {
					display: flex;
					flex-grow: 1;
					align-items: center;

					.iconfont {
						margin-right: 8rpx;
					}
				}

				.navigator-block {
					flex-grow: 0;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					font-size: 24rpx;

					.iconfont {
						background: #efefef;
						font-size: 34rpx;
						border-radius: 50%;
					}
				}
			}
		}

		.title1 {
			width: calc(100% - 80rpx);
			margin: 20rpx auto;
			font-weight: bold;
			border-left: 3px solid $color-primary;
			font-size: 32rpx;
			height: 34rpx;
			padding-left: 20rpx;
			display: flex;
			align-items: center;
		}

		.block {
			background: #fff;
			border-radius: 20rpx;
			padding: 30rpx;
			width: calc(100% - 80rpx);
			margin: 20rpx auto;
		}

		.block.photo-block {
			display: flex;
			flex-direction: column;

			.name {
				font-weight: bold;
				font-size: 36rpx;
				margin-bottom: 20rpx;
			}

			.photo {
				width: 100%;
				border-radius: 10rpx;
			}

			.price-block {
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-top: 20rpx;

				.discount-prices {
					font-weight: bold;
					color: $color-danger;
					flex-grow: 0;
					margin-right: 16rpx;
					font-size: 38rpx;
				}
			}
		}

		.block.detail-block {
			display: flex;
			flex-direction: column;
			margin-top: 20rpx;

			.title {
				font-weight: bold;
				font-size: 34rpx;
			}

			.detail-content {
				font-size: 28rpx;
				padding: 20rpx 0;
				padding-bottom: 20rpx;
			}
		}

		.block.booking {
			width: 100%;
			position: fixed;
			bottom: 0;
			left: 0;
			height: 120rpx;
			display: flex;
			align-items: center;
			justify-content: center;

		}
	}
</style>
